package com.hexacta.hrs.test.data;

import java.util.List;
import java.util.Map;

import org.vectrics.location.Locale;

/**
 * Test data dependency creator for the Locale class.
 * 
 * @author tpollak
 */
public class LocaleTestDataDependencyCreator extends AbstractTestDataDependencyCreator {

    public static final String ENGLISH_LOCALE = "ENGLISH_LOCALE";

    public static final String SPANISH_LOCALE = "SPANISH_LOCALE";

    public LocaleTestDataDependencyCreator(List<TestDataDependencyCreator> dependencies) {
        super(dependencies);
    }

    public void createDependentTestData(Map<String, Object> context) {
        Locale english = this.createLocale("en", "English");
        Locale spanish = this.createLocale("es", "Spanish");

        english = this.insertCodedObject(english);
        spanish = this.insertCodedObject(spanish);

        this.storeCodedObjectReferenceInContext(context, ENGLISH_LOCALE, english);
        this.storeCodedObjectReferenceInContext(context, SPANISH_LOCALE, spanish);
    }

    private Locale createLocale(String code, String description) {
        Locale locale = new Locale();
        locale.setCode(code);
        locale.setDescription(description);
        locale.setVoided(false);

        return locale;
    }
}
